function login(){
	var loading = HTR.msg('加载中', {icon: 16,time:60000});
	var params = HTR.getParams('.ipt');
	$.post(HTR.U('index/index/checkLogin'),params,function(data,textStatus){
		layer.close(loading);
		var json = HTR.toIndexJson(data);
		if(json.status=='1'){
			HTR.msg("登录成功",{icon:1},function(){
				location.href=HTR.U('index/index/index');
			});
		}else{
			getVerify('#verifyImg');
			HTR.msg(json.msg,{icon:2});			
		}
	});
}
getVerify = function(img){
	$(img).attr('src',HTR.U('index/index/getVerify','rnd='+Math.random()));
}

function toEditPass(){
	$('#editPassFrom')[0].reset();
	var w = HTR.open({type: 1,title:"忘记密码",shade: [0.6, '#000'],border: [0],content:$('#editPassBox'),area: ['400px', '260px'],
	    btn: ['确定', '取消'],yes: function(index, layero){
		  	var phone = $('#phone').val();
		  	var pass = $('#pass').val();
		  	var verify = $('#verify').val();
		  	var code = $('#code').val();
			if(phone == ''){
				HTR.msg('请输入手机号', {icon: 2});
			}else if(pass == ''){
				HTR.msg('请输入新密码', {icon: 2});
			}else if(verify == ''){
				HTR.msg('请输入图形验证码', {icon: 2});
			}else if(code == ''){
				HTR.msg('请输入短信验证码', {icon: 2});
			}else if(!/^1[3-578]\d{9}$/.test(phone)){
				HTR.msg('请填写正确的手机号码', {icon: 2});
			}else if(!/^[0-9a-zA-Z]{6,18}$/.test(phone)){
				HTR.msg('密码为6-18位字母、数字', {icon: 2});
			}else{					
	        	var ll = HTR.msg('数据处理中，请稍候...');
			    $.post(HTR.U('index/index/forgetPass'),{phone:phone,pass:pass,code:code},function(data){
			    	layer.close(ll);
			    	var json = HTR.toIndexJson(data);
					if(json.status==1){
						HTR.msg(json.msg, {icon: 1});
						layer.close(w);
						getVerify('#verifyImg');
					}else{
						HTR.msg(json.msg, {icon: 2});
					}
			   });
			}
        }
	});
}

var wait=60;
function r_time() {  
	if (wait == 0) {  
		$('.pin_btn').html('获取验证码').removeClass('pin_btn2');        
		wait = 60;  
	} else {
		$(".pin_btn").html(+wait+'秒后重试');
		wait--;  
		setTimeout(function() { r_time(); }, 1000);
	}  
}  
$('.pin_btn').click(function(){
	if($(this).hasClass('pin_btn2'))return false;
  	var phone = $('#phone').val();
  	var verify = $('#verify').val();
	if(phone == ''){
		HTR.msg('请输入手机号', {icon: 2});
	}else if(verify == ''){
		HTR.msg('请输入图形验证码', {icon: 2});
	}else if(!/^1[3-578]\d{9}$/.test(phone)){
		HTR.msg('请填写正确的手机号码', {icon: 2});
	}else{
    	$.post(HTR.U('index/index/sendSms'),{phone:phone,verify:verify},function(data){
	    	var json = HTR.toIndexJson(data);
			if(json.status==1){
		        $('.pin_btn').addClass('pin_btn2');        
		        r_time();
			}else{
				HTR.msg(json.msg, {icon: 2});
				getVerify('#verifyImg2');
			}			
	   });
  	}
})